<?php

namespace app\admin\model;

use think\Model;


class ActivityTake extends Model
{

    

    

    // 表名
    protected $name = 'activity_take';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = false;

    // 定义时间戳字段名
    protected $createTime = false;
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'active_typs_text',
        'stands_time_text',
        'create_time_text',
        'is_stands_text',
        'process_text',
        'process_time_text',
        'allot_time_text',
        'is_allot_text',
        'is_due_text',
        'update_time_text'
    ];
    

    
    public function getActiveTypsList()
    {
        return ['1' => __('Active_typs 1'), '2' => __('Active_typs 2')];
    }

    public function getIsStandsList()
    {
        return ['1' => __('Is_stands 1'), '2' => __('Is_stands 2')];
    }

    public function getProcessList()
    {
        return ['1' => __('Process 1'), '2' => __('Process 2') , '3' => __('Process 3')];
    }

    public function getIsAllotList()
    {
        return ['1' => __('Is_allot 1'), '2' => __('Is_allot 2')];
    }

    public function getIsDueList()
    {
        return ['1' => __('Is_due 1'), '2' => __('Is_due 2')];
    }


    public function getActiveTypsTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['active_typs']) ? $data['active_typs'] : '');
        $list = $this->getActiveTypsList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getStandsTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['stands_time']) ? $data['stands_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getCreateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['create_time']) ? $data['create_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getIsStandsTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_stands']) ? $data['is_stands'] : '');
        $list = $this->getIsStandsList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getProcessTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['process']) ? $data['process'] : '');
        $list = $this->getProcessList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getProcessTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['process_time']) ? $data['process_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getAllotTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['allot_time']) ? $data['allot_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }


    public function getIsAllotTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_allot']) ? $data['is_allot'] : '');
        $list = $this->getIsAllotList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getIsDueTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['is_due']) ? $data['is_due'] : '');
        $list = $this->getIsDueList();
        return isset($list[$value]) ? $list[$value] : '';
    }


    public function getUpdateTimeTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['update_time']) ? $data['update_time'] : '');
        return is_numeric($value) ? date("Y-m-d H:i:s", $value) : $value;
    }

    protected function setStandsTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setCreateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setProcessTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setAllotTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }

    protected function setUpdateTimeAttr($value)
    {
        return $value === '' ? null : ($value && !is_numeric($value) ? strtotime($value) : $value);
    }


}
